package cn.school.thoughtworks.section2;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

public class PracticeA {
    Map<String,Integer> countSameElements(List<String> collection1) {

        Map<String, Integer> nameMap = new HashMap();

        collection1.forEach(name -> nameMap.compute(name, (k, v) -> v == null ? 1 : ++v));
        return nameMap;
    }
}
